/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.hera.process.form.domain;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;

import com.hera.base.domain.BaseDomain;
import com.hera.process.config.domain.ParameterDetail;
import com.hera.process.external.domain.AddTableDetail;

/**
 *
 * @author cmontes
 */
@Entity
@Table(name = "FORM_FIELD")
public class FormField extends BaseDomain implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "Formfield")
    @TableGenerator(name = "Formfield", table = "sequence", pkColumnName = "seq_name", valueColumnName = "seq_id", pkColumnValue = "FORMFIELD", allocationSize = 1)
    @Column(name = "ID_FIELD")
    private Long idField;    
    private String name;
    private String description;
    @Column(name = "ID_TYPE")
    private Long idType;
    @ManyToOne
    @JoinColumn(name="ID_TYPE", insertable=false, updatable=false)
    private ParameterDetail type;
    private Integer length;
    private Boolean required;
    private String label;
    private String source;
    @Column(name = "ID_MODE")
    private Long idMode;
    @Column(name = "DEFAULT_VALUE")
    private String defaultValue;
    private String tooltip;
    @Column(name = "MAX_LENGTH")
    private Integer maxLength;
    @Column(name = "ID_VALIDATE")
    private Long idValidate;
    @Column(name = "NUMBER_ROWS")
    private Integer numberRows;
    @Column(name = "NUMBER_COLS")
    private Integer numberCols;
//    /*@JoinColumn(name = "ID_DYNAFORM", referencedColumnName = "ID_DYNAFORM")
//    @ManyToOne
//    private Dynaform dynaform;*/
    @Column(name = "ID_PROCESS")
    private Long idProcess;
    @JoinColumn(name = "ID_ADD_TABLE_DETAIL", referencedColumnName = "ID_ADD_TABLE_DETAIL")
    @ManyToOne
    private AddTableDetail addTableDetail;
    //@OneToMany(mappedBy = "formField")
    @Transient
    private List<FieldOption> fieldOptionList;
    
    @Column(name = "TOP")
    private Integer top;
    @Column(name = "LEFT")
    private Integer left;
    /*
    @Column(name = "ID_TABLE_FORM")
    private Long idTableForm;*/
    @JoinColumn(name = "ID_TABLE_FORM", referencedColumnName = "ID_DYNAFORM")
    @ManyToOne
    private Dynaform tableForm;

    public FormField() {
    }

    public FormField(Long idField) {
        this.idField = idField;
    }

    public Long getIdField() {
        return idField;
    }

    public void setIdField(Long idField) {
        this.idField = idField;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Long getIdType() {
        return idType;
    }

    public void setIdType(Long idType) {
        this.idType = idType;
    }

    public Integer getLength() {
        return length;
    }

    public void setLength(Integer length) {
        this.length = length;
    }
        
	
	public Boolean getRequired() {
		return required;
	}

	public void setRequired(Boolean required) {
		this.required = required;
	}

	public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public Long getIdMode() {
        return idMode;
    }

    public void setIdMode(Long idMode) {
        this.idMode = idMode;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public void setDefaultValue(String defaultValue) {
        this.defaultValue = defaultValue;
    }

    public String getTooltip() {
        return tooltip;
    }

    public void setTooltip(String tooltip) {
        this.tooltip = tooltip;
    }

    public Integer getMaxLength() {
        return maxLength;
    }

    public void setMaxLength(Integer maxLength) {
        this.maxLength = maxLength;
    }

    public Long getIdValidate() {
        return idValidate;
    }

    public void setIdValidate(Long idValidate) {
        this.idValidate = idValidate;
    }

    public Integer getNumberRows() {
        return numberRows;
    }

    public void setNumberRows(Integer numberRows) {
        this.numberRows = numberRows;
    }

    public Integer getNumberCols() {
        return numberCols;
    }

    public void setNumberCols(Integer numberCols) {
        this.numberCols = numberCols;
    }

/*
    public Dynaform getDynaform() {
        return dynaform;
    }

    public void setDynaform(Dynaform dynaform) {
        this.dynaform = dynaform;
    }*/

    public AddTableDetail getAddTableDetail() {
        return addTableDetail;
    }

    public void setAddTableDetail(AddTableDetail addTableDetail) {
        this.addTableDetail = addTableDetail;
    }

    public List<FieldOption> getFieldOptionList() {
        return fieldOptionList;
    }

    public void setFieldOptionList(List<FieldOption> fieldOptionList) {
        this.fieldOptionList = fieldOptionList;
    }

    
    public Integer getTop() {
		return top;
	}

	public void setTop(Integer top) {
		this.top = top;
	}

	public Integer getLeft() {
		return left;
	}

	public void setLeft(Integer left) {
		this.left = left;
	}
	
	public Long getIdProcess() {
		return idProcess;
	}
	
	public void setIdProcess(Long idProcess) {
		this.idProcess = idProcess;
	}	

	public ParameterDetail getType() {
		return type;
	}

	public void setType(ParameterDetail type) {
		this.type = type;
	}	

	
	public Dynaform getTableForm() {
		return tableForm;
	}

	public void setTableForm(Dynaform tableForm) {
		this.tableForm = tableForm;
	}

	@Override
    public int hashCode() {
        int hash = 0;
        hash += (idField != null ? idField.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        
        if (!(object instanceof FormField)) {
            return false;
        }
        FormField other = (FormField) object;
        if ((this.idField == null && other.idField != null) || (this.idField != null && !this.idField.equals(other.idField))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.hera.process.data.domain2.FormField[ idField=" + idField + " ]";
    }
    
}
